public class ModelAttributeMethodArgumentResolver extends HandlerMethodArgumentResolverSupport
@ModelAttribute
annotated method arguments.
Model attributes are sourced from the model, or created using a default
constructor and then added to the model. Once created the attribute is
populated via data binding to the request (form data, query params).
Validation also may be applied if the argument is annotated with
@javax.validation.Valid
or Spring's own
@org.springframework.validation.annotation.Validated
.
When this handler is created with useDefaultResolution=true
any non-simple type argument and return value is regarded as a model
attribute with or without the presence of an @ModelAttribute
.
Modifier and Type | Field and Description |
---|---|
private static ParameterNameDiscoverer |
parameterNameDiscoverer |
private boolean |
useDefaultResolution |
Constructor and Description |
---|
ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry,
boolean useDefaultResolution)
Class constructor with a default resolution mode flag.
|
Modifier and Type | Method and Description |
---|---|
private <any> |
constructAttribute(java.lang.reflect.Constructor<?> ctor,
java.lang.String attributeName,
BindingContext context,
ServerWebExchange exchange) |
private <any> |
createAttribute(java.lang.String attributeName,
java.lang.Class<?> clazz,
BindingContext context,
ServerWebExchange exchange) |
private java.lang.Object |
findAndRemoveReactiveAttribute(Model model,
java.lang.String attributeName) |
private boolean |
hasErrorsArgument(MethodParameter parameter) |
private <any> |
prepareAttributeMono(java.lang.String attributeName,
ResolvableType attributeType,
BindingContext context,
ServerWebExchange exchange) |
<any> |
resolveArgument(MethodParameter parameter,
BindingContext context,
ServerWebExchange exchange)
Resolve the value for the method parameter.
|
boolean |
supportsParameter(MethodParameter parameter)
Whether this resolver supports the given method parameter.
|
private void |
validateIfApplicable(WebExchangeDataBinder binder,
MethodParameter parameter) |
checkAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistry
private static final ParameterNameDiscoverer parameterNameDiscoverer
private final boolean useDefaultResolution
public ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry, boolean useDefaultResolution)
adapterRegistry
- for adapting to other reactive types from and to MonouseDefaultResolution
- if "true", non-simple method arguments and
return values are considered model attributes with or without a
@ModelAttribute
annotation present.public boolean supportsParameter(MethodParameter parameter)
HandlerMethodArgumentResolver
parameter
- the method parameterpublic <any> resolveArgument(MethodParameter parameter, BindingContext context, ServerWebExchange exchange)
HandlerMethodArgumentResolver
parameter
- the method parametercontext
- the binding context to useexchange
- the current exchangeMono
for the argument value, possibly emptyprivate <any> prepareAttributeMono(java.lang.String attributeName, ResolvableType attributeType, BindingContext context, ServerWebExchange exchange)
@Nullable private java.lang.Object findAndRemoveReactiveAttribute(Model model, java.lang.String attributeName)
private <any> createAttribute(java.lang.String attributeName, java.lang.Class<?> clazz, BindingContext context, ServerWebExchange exchange)
private <any> constructAttribute(java.lang.reflect.Constructor<?> ctor, java.lang.String attributeName, BindingContext context, ServerWebExchange exchange)
private boolean hasErrorsArgument(MethodParameter parameter)
private void validateIfApplicable(WebExchangeDataBinder binder, MethodParameter parameter)